import React, { Component } from 'react';
/*
2.子传父 
 */
class Tesing extends Component {
    state={
        msg:""
    }
    handleClick=(e) => {
        console.log(e)
       this.setState({
           msg:e
       })
    }
    render() {
        return (
            <div>
                子组件传过来的值{this.state.msg}
                <Tesingchild handPclick={this.handleClick} ></Tesingchild>
            </div>
        );
    }
}
class Tesingchild extends Component{
    state={
        msg:"🐕"
    }
    touchPass=(params) => {
        this.props.handPclick(this.state.msg)
    }
    render(){
        return(
            <div>子组件
                {/* 不额外添加函数的情况下 */}
                {/* <button onClick={()=>{ this.props.handPclick(this.state.msg)}}>传值给父组件</button> */}
                <button onClick={this.touchPass}>传值给父组件</button>
            </div>
            
        )
    }
}
export default Tesing;